Skip to content

Sets the UART pins internally #8616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Sep 7, 2023

Description of Change

There is a bug in HardwareSerial::setPins() that sets the UART pins internally to the wrong value at the end of the operation, which may lead to errors in HardwareSerial::end(), not dettaching the right GPIO from UART.

This PR also makes sure that sequential HardwareSerial::setPins() will always detach previous attached GPIOs.

Tests scenarios

// Check previous GPIOs with a Logic Analyzer
void setup() {
  Serial.begin(115200);  // sets default RX and TX
  Serial.println("This will go out in the default TX pin");
  Serial.flush();
  
  Serial.setPins(-1, 2);  // Now TX shall be GPIO2 and default TX GPIO can't send any data
  Serial.println("This line can't be seen in the default TX GPIO!");
  Serial.flush();
}

void loop(){
}

Related links

Closes #8607

@SuGlider SuGlider self-assigned this Sep 7, 2023
@SuGlider SuGlider linked an issue Sep 7, 2023 that may be closed by this pull request
1 task
Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuGlider PTAL

@SuGlider
Copy link
Collaborator Author

SuGlider commented Sep 8, 2023

Closing it in favor of #8619 -- for rebasing it to master branch

@SuGlider SuGlider closed this Sep 8, 2023
@SuGlider SuGlider deleted the UART_pinSet branch September 8, 2023 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HardwareSerial::setPins does not unset previous pin
2 participants